//
// Description: 2816. 判断子序列
// Created by Loading on 2022/5/25.
//

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1e5 + 10;

int main() {
    int n, m;
    cin >> n >> m;

    int a[N], b[N];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    // 双指针
    int i = 0;
    for (int j = 0; i < n && j < m;) {
        if (a[i] == b[j]) {
            ++i;
        }
        ++j;
    }
    if (i == n) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}